import * as React from "react";
import Button from "@mui/material/Button";
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import { Slide } from "@mui/material";
export default function ConfirmDialog(props) {
  /**
   * open: bool 是否开启
   * open: bool 是否开启
   * handleClose: 关闭函数
   * handleConfirm: 确认函数
   */
  const Transition = React.forwardRef(function Transition(props, ref) {
    return <Slide direction="up" ref={ref} {...props} />;
  });

  return (
    <div>
      <Dialog
        open={props.open}
        // TransitionComponent={Transition}
        // keepMounted
        onClose={props.handleClose}
        aria-describedby="alert-dialog-slide-description"
      >
        <DialogTitle>{props.title ?? "警告"}</DialogTitle>
        <DialogContent>
          <DialogContentText id="alert-dialog-slide-description">
            {props.text}
          </DialogContentText>
        </DialogContent>
        <DialogActions>
          <Button onClick={props.handleClose}>取消</Button>
          <Button color="error" onClick={props.handleConfirm}>
            确认
          </Button>
        </DialogActions>
      </Dialog>
    </div>
  );
}
